{include file='public/header.html'}

<div class="jumbotron text-center">
    <div style="position: absolute;top: 20%;width: 100%;">
        <h2>{:site('site_h1', '无念的编程圈')}</h2>
        <p>{:site('site_h2', '网址：https://www.aphp.top')}</p>
    </div>
</div>

<div class="blog container mtn">

    <div class="row">
        <div class="col-sm-9">

            <div class="well clearfix">
                <strong>公告：<span class="text-danger">{site('site_notice') ?: '暂无公告！'}</span></strong>
            </div>

            {php $category=widget('common.category')->get()}

            <div class="row mtn">
                {php $list=db('article')->field('id,thumb,title,summary,category_id,tag_ids,user_id,author,is_top,read_count,update_time')->where('status=1')->order('is_top DESC,update_time DESC,id DESC')->paginate(16)}

                {php $offset=$list->attr('offset')}
                {foreach $list as $k=>$vo}
                {php $k=$k+1+$offset}
                {if $k<=2:}
                <div class="col-sm-6">
                    <div class="media">
                        <div class="media-left media-top">
                            <a href="{:url('article/detail',['id'=>$vo['id']])}"><img src="{:rand_thumb($vo['thumb'], $k)}" alt="thumb" /></a>
                        </div>
                        <div class="media-body">
                            <div class="media-heading">
                                {if $vo['is_top']==1:}<span class="text-danger">置顶</span>{/if} <a href="{:url('article/detail',['id'=>$vo['id']])}">{$vo.title}</a>
                            </div>
                            <div class="media-content">
                                {$vo.summary|str_substr=60}
                            </div>
                            <div class="media-footer">
                                <a href="{:url('article/index',['cid'=>$vo['category_id']])}"><i class="glyphicon glyphicon-th-list"></i> {$category[$vo['category_id']]}</a>
                                <a href="{:url('article/detail',['id'=>$vo['id']])}" class="read pull-right">阅读</a>
                            </div>
                        </div>
                    </div>
                </div>
                {else:}
                <div class="col-sm-12">
                    <div class="media">
                        <div class="media-left media-top">
                            <a href="{:url('article/detail',['id'=>$vo['id']])}"><img src="{:rand_thumb($vo['thumb'], $k)}" alt="thumb" /></a>
                        </div>
                        <div class="media-body">
                            <div class="media-heading">
                                {if $vo['is_top']==1:}<span class="text-danger">置顶</span>{/if} <a href="{:url('article/detail',['id'=>$vo['id']])}">{$vo.title}</a>
                            </div>
                            <div class="media-content">
                                {$vo.summary}
                            </div>
                            <div class="media-footer">
                                <i class="glyphicon glyphicon-user"></i> <a href="{:url('user/info',['id'=>$vo['user_id']])}">{$vo.author}</a>&nbsp;&nbsp;
                                <a href="{:url('article/index',['cid'=>$vo['category_id']])}"><i class="glyphicon glyphicon-th-list"></i> {$category[$vo['category_id']]}</a>&nbsp;&nbsp;
                                <i class="glyphicon glyphicon-time"></i> {:date('Y-m-d', $vo['update_time'])}&nbsp;&nbsp;
                                <i class="glyphicon glyphicon-eye-open"></i> {$vo.read_count}&nbsp;&nbsp;
                                {!empty $vo['tag_ids']:}
                                <span class="pull-right">
                                    {php $tags=widget('common.tags')->get($vo['tag_ids'], ['key'=>'sign'])}
                                    {foreach $tags as $sign=>$name}
                                    <a href="{:url('article/index', ['tag'=>$sign])}">#{$name}</a>&nbsp;&nbsp;
                                    {/foreach}
                                </span>
                                {/empty}
                            </div>
                        </div>
                    </div>
                </div>
                {/if}
                {/foreach}
                {empty $list->toArray():}
                <div class="well" style="margin: 0 15px;">暂无文章！</div>
                {/empty}



            </div>
            {$list->links()}

        </div>
        <div class="col-sm-3">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="glyphicon glyphicon-user"></i> 作者
                </div>
                <div class="panel-body">
                    {php $my=db('user')->field('id,nickname,avatar,qq,bio')->where('id', 1)->cache()->find()}
                    <div class="thumbnail text-center" style="margin-bottom: 0;">
                        <img src="{:get_avatar($my['avatar'], $my['qq'])}" width="80" height="80" class="img-circle" alt="avatar"/>
                        <div class="caption">
                            <p style="margin-top:5px;">
                                <a href="{:url('user/info',['id'=>$my['id']])}"><strong>{$my.nickname}</strong></a>
                            </p>
                            <p>#{$my.bio}</p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="glyphicon glyphicon-th-list"></i> 分类
                </div>
                <div class="panel-body">

                    <ul class="list-unstyled">
                        <li><a href="{:url('article/index')}">全部</a></li>
                        {foreach $category as $k=>$v}
                        <li><a href="{:url('article/index',['cid'=>$k])}">{$v}</a></li>
                        {/foreach}
                    </ul>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="glyphicon glyphicon-search"></i> 搜索
                </div>
                <div class="panel-body">
                    <form class="form-inline">
                        <div class="form-group">
                            <div class="input-group">
                                <input type="text" class="form-control" id="keyword" placeholder="请输入关键词..." />
                                <div class="input-group-addon" id="search" style="cursor:pointer;">
                                    <i class="glyphicon glyphicon-search"></i>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="glyphicon glyphicon-fire"></i> 热门
                </div>
                <div class="panel-body">
                    {php $hot=db('article')->field('id,title,read_count')->where('status=1')->order('read_count DESC')->limit(10)->select()}
                    <ul class="list-unstyled">
                        {foreach $hot as $k=>$v}
                        {php $k=$k+1}
                        <li><a href="{:url('article/detail',['id'=>$v['id']])}">{$k}. {$v.title}</a><span class="pull-right">{$v.read_count}</span></li>
                        {/foreach}
                    </ul>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="glyphicon glyphicon-tags"></i> 标签
                </div>
                <div class="panel-body">
                    {php $tags=widget('common.tags')->get('', ['key'=>'sign'])}
                    {foreach $tags as $sign=>$name}
                    <a href="{:url('article/index', ['tag'=>$sign])}">#{$name}</a>&nbsp;&nbsp;
                    {/foreach}
                </div>
            </div>

        </div>

    </div>

</div>

{include file='public/footer.html'}
<script src="__STATIC__/js/jquery.particleground.min.js"></script>
<script>
    $(document).ready(function () {
        $('.jumbotron').particleground({ dotColor: 'rgba(255,255,255,0.3)',lineColor: 'rgba(255,255,255,0.2)',density:20000 });
        $('#search').click(function () {
            "" != $("#keyword").val() ? location.href = "{:url('article/index')}?keyword=" + $("#keyword").val() : toast('请输入关键字');
        });
    });
</script>
</body>
</html>